package com.brand.prisd.ViewHolder;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.constraint.ConstraintLayout;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.brand.prisd.R;
import com.brand.prisd.activity.AddDeviceActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.brand.prisd.bean.VariableStorage.AllDevicesActivity_Devices;
import static com.brand.prisd.bean.VariableStorage.ChooseDeviceTypeActivity_DeviceName;

/**
 * Created by HJ on 2019/1/2.
 */
public class Type6ViewHolder extends RecyclerView.ViewHolder {
    @BindView(R.id.iv_deviceIcon)
    ImageView ivDeviceIcon;
    @BindView(R.id.tv_deviceName)
    TextView tvDeviceName;
    @BindView(R.id.cl_container)
    ConstraintLayout clContainer;
    private Context context;
    private int position;
    public Type6ViewHolder(@NonNull View itemView) {
        super(itemView);
        context = itemView.getContext();
        ButterKnife.bind(this, itemView);

    }

    @OnClick({R.id.cl_container})
    public void onViewClicked(View view) {
        switch (position) {
            case 2:
                go2AddDeviceActivity();
                break;
           default:
                Toast.makeText(context, "待开发...", Toast.LENGTH_SHORT).show();
                break;
        }
    }

    private void go2AddDeviceActivity() {
        Intent intent = new Intent(context, AddDeviceActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);

    }


    public void setDataInChooseDeviceTypeActivity(int position) {
        tvDeviceName.setText(ChooseDeviceTypeActivity_DeviceName[position - 2]);
    }

    public void setDataInAllDevicesActivity(int position) {
        this.position = position;
        tvDeviceName.setText(AllDevicesActivity_Devices[position]);
    }
}
